package com.xieyingwangluo.yxpart.api;

import com.xieyingwangluo.yxpart.bean.Result;
import com.xieyingwangluo.yxpart.entity.UserInfoModel;
import com.xieyingwangluo.yxpart.logic.UserInfoLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Api(tags = "userinfo接口")
@Controller
@RequestMapping(value = "/api/v1/userinfo")
public class UserInfoBaseRest extends BaseRest {
    @Autowired
    private UserInfoLogic userInfoLogic;

    //添加
//    @ApiOperation(value = "添加用户信息", notes = "添加用户信息", produces = "application/json")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "noid", value = "用户信息编号", required = false, dataType = "String", paramType = "form"),
//            @ApiImplicitParam(name = "name", value = "名称", required = true, dataType = "String", paramType = "form", defaultValue = "张三"),
//            @ApiImplicitParam(name = "sex", value = "性别", required = false, dataType = "int", paramType = "form", defaultValue = "1"),
//            @ApiImplicitParam(name = "birth", value = "出生年月", required = true, dataType = "String", paramType = "form", defaultValue = "20141012"),
//            @ApiImplicitParam(name = "idnumb", value = "身份证号", required = true, dataType = "String", paramType = "form", defaultValue = "178909890989098789"),
//            @ApiImplicitParam(name = "county", value = "城市区域", required = true, dataType = "String", paramType = "form", defaultValue = "河北省石家庄市桥西区"),
//            @ApiImplicitParam(name = "address", value = "地址", required = true, dataType = "String", paramType = "form", defaultValue = "红旗大街2号"),
//            @ApiImplicitParam(name = "height", value = "身高", required = true, dataType = "int", paramType = "form", defaultValue = "180"),
//            @ApiImplicitParam(name = "weight", value = "体重", required = true, dataType = "int", paramType = "form", defaultValue = "160"),
//            @ApiImplicitParam(name = "qq", value = "qq", required = true, dataType = "String", paramType = "form", defaultValue = "2980980098"),
//            @ApiImplicitParam(name = "email", value = "邮箱", required = true, dataType = "String", paramType = "form", defaultValue = "8909789899@qq.com"),
//            @ApiImplicitParam(name = "info", value = "自我评价", required = true, dataType = "String", paramType = "form", defaultValue = "超厉害的！"),
//            @ApiImplicitParam(name = "user_id", value = "用户id", required = false, dataType = "String", paramType = "form", defaultValue = "44aa8b4d-a687-11e8-bf73-000c2984c921"),
//            @ApiImplicitParam(name = "state", value = "状态", required = false, dataType = "int", paramType = "form", defaultValue = "1")
//
//
//    })
//    @ResponseBody
//    @PostMapping(value = "/add")
//    public Result add(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
//                      HttpSession session,
//                      UserInfoModel userInfoModel) {
//        return userInfoLogic.add(session, userInfoModel);
//    }

    //个人评价：
    //显示：用户信息编号（noid)

    @ApiOperation(value = "显示个人详细信息", notes = "显示个人详细信息", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "登录用户id", required = true, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @GetMapping(value = "/selInfo")
    public Result selInfo(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                          @RequestParam("noid") String noid
    ) {
        return userInfoLogic.selInfo(noid);
    }

    //显示：用户信息编号（noid）
    @ApiOperation(value = "显示用户信息", notes = "显示用户信息", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "登录用户id", required = true, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @GetMapping(value = "/selO")
    public Result selO(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                       @RequestParam("noid") String noid
    ) {
        return userInfoLogic.selO(noid);
    }

    //修改状态：用户信息编号(userinfo_id)，状态(state)
    //管理员审核普通用户
//    @ApiOperation(value = "修改用户信息", notes = "修改用户信息", produces = "application/json")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "state", value = "状态", required = true, dataType = "int", paramType = "query", defaultValue = "0")
//    })
//    @ResponseBody
//    @PutMapping(value = "/updS")
//    public Result updS(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
//                       HttpSession session,
//                       @RequestParam("state") int state
//    ) {
//        return userInfoLogic.updS(session, state);
//    }

    @ApiOperation(value = "查询用户信息", notes = "查询用户信息", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "用户信息编号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "sex", value = "性别", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "birth", value = "出生年月", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "idnumb", value = "身份证号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "county", value = "城市区域", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "address", value = "地址", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "height", value = "身高", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "weight", value = "体重", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "qq", value = "qq", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "email", value = "邮箱", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "info", value = "自我评价", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "user_id", value = "用户id", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "state", value = "状态", required = false, dataType = "int", paramType = "query")


    })
    @ResponseBody
    @GetMapping(value = "/selA")
    public Result selA(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                       UserInfoModel userInfoModel) {
        return userInfoLogic.selA(userInfoModel);
    }

    //单个用户信息显示
//    @ApiOperation(value = "显示用户信息", notes = "显示用户信息", produces = "application/json")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "noid", value = "用户信息id", required = true, dataType = "String", paramType = "query", defaultValue = "0b6f0f71-a6ab-11e8-b52f-000c2984c921")
//    })
//    @ResponseBody
//    @GetMapping(value = "/selN")
//    public Result selN(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
//                       @RequestParam("noid") String noid) {
//        return userInfoLogic.selN(noid);
//    }

    //修改用户信息
    @ApiOperation(value = "修改用户信息", notes = "修改用户信息", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "用户信息编号", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "sex", value = "性别", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "birth", value = "出生年月", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "idnumb", value = "身份证号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "county", value = "城市区域", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "address", value = "地址", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "height", value = "身高", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "weight", value = "体重", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "qq", value = "qq", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "email", value = "邮箱", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "info", value = "自我评价", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "user_id", value = "登录用户id 不能更改", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "state", value = "状态", required = false, dataType = "int", paramType = "query")
    })
    @ResponseBody
    @PutMapping(value = "/upd")
    public Result upd(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                      UserInfoModel userInfoModel) {
        return userInfoLogic.upd(userInfoModel);
    }
}
